import {
  createRouter,
  createWebHistory,
  Router,
  RouteRecordRaw,
} from "vue-router";

const routes: RouteRecordRaw[] = [
  {
    path: "/",
    meta: {
      unRequiresAuth: true, // 无需登陆标识
    },
    redirect: "/login",
  },
  {
    path: "/login",
    name: "Login", // 重定向标识、判断是否需要进行用户登陆检查
    meta: {
      unRequiresAuth: true, // 无需登陆标识
    },
    component: () => import("@views/login/index.vue"),
  },
  {
    path: "/register",
    meta: {
      unRequiresAuth: true, // 无需登陆标识
    },
    component: () => import("@views/register/index.vue"),
  },
  {
    path: "/home",
    component: () => import("@views/home/index.vue"),
    redirect: "/home/opt",
    children: [
      {
        path: "/home/opt",
        component: () => import("@views/study/OptionApi.vue"),
      },
      {
        path: "/home/com",
        component: () => import("@views/study/CompositionApi.vue"),
      },
    ],
  },
];

const router: Router = createRouter({
  history: createWebHistory(), // history模式
  // history: createWebHashHistory(), // hash模式
  routes,
});

export default router;
